# Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.

import os
from waflib import Logs

def build(bld):
	platform = bld.env['PLATFORM']
	spec = bld.options.project_spec
	configuration = bld.env['CONFIGURATION']

	if platform and not platform == 'project_generator' and not bld.cmd == 'generate_uber_files' and 'CryAudioImplFmod' in bld.spec_modules(spec, platform, configuration):
		if not os.path.isdir('Code/SDKs/Audio/fmod'):
			Logs.error('[ERROR] Attempting to build CryAudioImplFmod, but could not find the Fmod SDK at Code/SDKs/Audio/fmod, skipping.')
			return

	bld.CryEngineModule(
		target      = 'CryAudioImplFmod',
		vs_filter   = 'CryEngine/Audio/Implementations',
		file_list   = 'cryaudioimpl_fmod.waf_files',
		pch         = 'stdafx.cpp',

		### GENERAL ###
		debug_defines       = 'FMOD_FOR_DEBUG',
		profile_defines     = 'FMOD_FOR_PROFILE',
		performance_defines = 'FMOD_FOR_RELEASE',
		release_defines     = 'FMOD_FOR_RELEASE',

		includes = '../../Common',
		
		### WINDOWS ###
		win_includes = [
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/windows/api/lowlevel/inc'),
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/windows/api/studio/inc')
		],

		win_libpath = [
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/windows/api/lowlevel/lib'),
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/windows/api/studio/lib')
		],

		win_x86_lib = ['fmod_vc', 'fmodstudio_vc'],
		win_x64_lib = ['fmod64_vc', 'fmodstudio64_vc'],
		
		### LINUX ###
		linux_includes = [
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/linux/api/lowlevel/inc'),
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/linux/api/studio/inc')
		],

		linux_x86_libpath = [
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/linux/api/lowlevel/lib/x86'),
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/linux/api/studio/lib/x86')
		],

		linux_x64_libpath = [
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/linux/api/lowlevel/lib/x86_64'),
		bld.CreateRootRelativePath('Code/SDKs/Audio/fmod/linux/api/studio/lib/x86_64')
		],

		linux_lib = ['fmod', 'fmodstudio'],
		module_extensions = [ 'audio_fmod' ],

		### XBOXONE ###
		durango_lib = 'acphal',
	)
